<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title></title>
        <script src="https://cdn.jsdelivr.net/npm/vue@2.5.21/dist/vue.js" type="text/javascript"charset="utf-8"></script>
    </head>

    <body>
        <!-- view -->
        <div id="app">
            <!-- 
              1. 用组件来生成li标签
              2. 遍历items
              3. 将item数据传递给模板中的props
              4. 从props中取数据element，放入模板的li标签中
             -->
            <part v-for="item in items" v-bind:element="item"></part>
        </div>


        <script type="text/javascript">
            // 自定义组件相当于虚拟DOM，拿到值后传递给真的模板
            Vue.component("part", {
              props: ['element'],
              template: '<li>{{element}}</li>'
            })

            let app = new Vue({
                el: "#app",
                data: {
                  items: ["java", "linux", "mysql", "vue"]
                }
            })
        </script>
    </body>
</html>